Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add .asRegExp() method to return regexp for route #27

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

simonflk
Copy link

I'm using route-parser in my react app, and it's working great, thank you!
And my local dev server is serving 2 single-page apps using connect-history-api-fallback to determine which one to serve based on the URL.

Thus far I've manually crafted a regexp, then moved on to writing my own route-parser route -> regexp parser, and quickly decided that was a bit silly since route-parser can give me the regular expressions.

So here I am with a PR to expose the regexp on the route.
I'm interested to know what your thoughts on this are. Personally I'm happy to continue using the regexp visitor in my code, but I'd feel better knowing that was stable/documented. I'm happy to submit a PR for docs instead.

Another solution would be to modify connect-history-api-fallback to accept a function in place of a regexp. But I'm not a direct consumer of that module. Rather I'm using webpack-dev-server, which uses that under the hood.

@rcs
Copy link
Owner

rcs commented Apr 17, 2017

I'm glad you find this useful!

I like this. It makes sense, it makes it easier to use in more environments, and it hadn't occured to me how useful hat might be.

I am a little bit apprehensive, however, because I'm not entirely sure that this is an API that continues to make sense if a candidate for specifying query parameters ever works for this library, since I'm not sure that a regex will still be the solution. (Extracting query parameters, and specifying them, is a common request.)

That said: If it comes down to that, it would also be a reason to bump a major version if it couldn't be supported, and that's not the end of the world.

Thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants